// pages/my/tranPlan/index.js
var App = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		list:'',
		api:App.api,
		nums: 0,
		page: 2
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		var id = options.id;
		var that = this;
		that.setData({
			id: id
		})

		that.getTranPlan();
	},
	getTranPlan: function () {
		var that = this;
		App.ajax.ajax('schdule.do?method=actListBySchid', {
			JSESSIONID: wx.getStorageSync('JSESSIONID'),
			i_bb_schedule_id: that.data.id,
			page: 1,
			limit:6
		}, function (res) {
			console.log(res.data)
			 that.setData({
				list:res.data.items 
			 })
		
		})
	},
	getpage: function (page) {
		var that = this;
		if (that.data.page > that.data.nums) {
			wx.showToast({
				title: '已加载全部',
				icon: 'none'
			})
		}
		else {
			App.ajax.ajax('userInfo.do?method=testScheduleList', {
				page: page,
				JSESSIONID: wx.getStorageSync('JSESSIONID'),
				limit: 6
			}, function (res) {
				// for (var i = 0; i < res.data.items.length; i++) {
				// 	res.data.items[i].register_date = (res.data.items[i].register_date).substring(0, 10);
				// }
				var list = that.data.list;
				var allData = list.concat(res.data.items);
				that.setData({
					list: allData,
					page: that.data.page + 1
				})
			})
		}
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {
		var that = this;
		var page = that.data.page;
		that.getpage(page);
	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})